package com.group01.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.github.yulichang.base.MPJBaseMapper;
import com.group01.pojo.Address;
import com.group01.vo.Address.AddressGetInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 19559
* @description 针对表【es_address(收货地址表)】的数据库操作Mapper
* @createDate 2024-06-23 10:14:14
* @Entity com.group01.pojo.Address
*/
public interface AddressMapper extends MPJBaseMapper<Address> {
    /**
     * 获取用户所有收货地址
     */
    List<AddressGetInfoVO> getAllAddress(@Param(Constants.WRAPPER) Wrapper<AddressGetInfoVO> wrapper);

    /**
     * 查询用户是否有这一地址
     */
    @Select("select count(*) from es_address where user_id = #{userId} and id = #{addressId}")
    Integer checkUserAddress(@Param("userId") Integer userId , @Param("addressId") Integer addressId);

    /**
     * 检查收货地址是否存在
     */
    @Select("select count(*) from es_address where id = #{addressId}")
    Integer checkAddress(@Param("addressId") Integer addressId);
}




